﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GStringBuilder
{
    private static System.Text.StringBuilder mstrbuilder = new System.Text.StringBuilder();
    /// <summary>
    /// 合并字符
    /// </summary>
    /// <param name="args"></param>
    /// <returns></returns>
    public static string Contact(params object[] args)
    {
        if (mstrbuilder.Length >= 0)
            mstrbuilder.Remove(0, mstrbuilder.Length);
        else
            mstrbuilder.Clear();

        if (args != null)
        {
            int len = args.Length;
            for (int i = 0; i < len; ++i)
            {
                mstrbuilder.Append(args[i]);
            }
        }
        return mstrbuilder.ToString();
    }


    /// <summary>
    /// 合并字符
    /// </summary>
    /// <param name="str1"></param>
    /// <param name="str2"></param>
    /// <param name="args">star2的参数</param>
    /// <returns></returns>
    public static string AppendContact(string str1,string str2,params object[] args)
    {
        if (mstrbuilder.Length >= 0)
            mstrbuilder.Remove(0, mstrbuilder.Length);
        else
            mstrbuilder.Clear();

        mstrbuilder.Append(str1);
        mstrbuilder.AppendFormat(str2, args);

        return mstrbuilder.ToString();
    }

    /// <summary>
    /// 合并字符
    /// </summary>
    /// <param name="str1"></param>
    /// <param name="args">star1的参数</param>
    /// <returns></returns>
    public static string Format(string str2, params object[] args)
    {
        if (mstrbuilder.Length >= 0)
            mstrbuilder.Remove(0, mstrbuilder.Length);
        else
            mstrbuilder.Clear();

        mstrbuilder.AppendFormat(str2, args);

        return mstrbuilder.ToString();
    }
}
